package com.cskaoyan.service.wx;

import com.cskaoyan.bean.*;
import com.cskaoyan.bean.wxbean.WxGoodsDetailBean.CommentWx;
import com.cskaoyan.bean.wxbean.WxGoodsDetailBean.SpecificationWx;
import com.cskaoyan.bean.wxbean.WxGoodsDetailBean.WxGroupon;
import com.cskaoyan.mapper.wx.WxGoodsDetailMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Enzo Cotter on 2020/10/8.
 */
@Service
public class WxGoodsDetailServiceImpl implements WxGoodsDetailService {
    @Autowired
    WxGoodsDetailMapper wxGoodsDetailMapper;
    @Override
    public Goods queryOneById(Integer goodsId) {
        return wxGoodsDetailMapper.queryOneById(goodsId);
    }

    @Override
    public List<Attribute> getAttributeByGoodsId(Integer goodsId) {
        return wxGoodsDetailMapper.getAttributeByGoodsId(goodsId);
    }

    @Override
    public Brand getBrandById(Integer brandId) {
        return wxGoodsDetailMapper.selectByPrimaryKey(brandId);
    }

    @Override
    public List<CommentWx> getCommentsByGoodsId(Integer goodsId) {
        return wxGoodsDetailMapper.getCommentsByGoodsId(goodsId);
    }

    @Override
    public int getCommentCountByGoodsId(Integer goodsId) {
        return wxGoodsDetailMapper.getCommentCountByGoodsId(goodsId);
    }


    @Override
    public List<Issue> getAllIssue() {
        return wxGoodsDetailMapper.getAllIssue();
    }

    @Override
    public List<Product> queryByGoodsId(Integer goodsId) {
        return wxGoodsDetailMapper.queryByGoodsId(goodsId);
    }

    @Override
    public List<SpecificationWx> querySpecificationWxByGoodsId(Integer goodsId) {
        return wxGoodsDetailMapper.querySpecificationWxByGoodsId(goodsId);
    }

    @Override
    public int verifyCollectByUserIdAndGoodsId(Integer goodsId, Integer userId) {
        Collect collect = wxGoodsDetailMapper.verifyCollectByUserIdAndGoodsId(goodsId, userId);
        if (collect != null){
            return 1;
        }
        return 0;
    }
}
